﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bat_sym.SimulationLogic.Rules
{
    class Hunting : ISimulationRule
    {
        private Random _rng;

        public Hunting(double prob_to_hunt)
        {
            RuleName = "Hunting";
            Parameters.Add("Hunt probability", prob_to_hunt);
            _rng = new Random();
        }

        public override void Execute(System.Collections.ObjectModel.ObservableCollection<Models.Bat> bats)
        {
            double prob = Parameters["Hunt probability"];
            foreach (Models.Bat bat in bats.Where(bat => bat.alive))
            {
                double nr = _rng.Next(100);
                
                    if (nr <= prob)
                    {
                        bat.FoodAmmount = 100;
                    }
            }
        }
    }
}
